﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SockLib.Device.ModbusDevices
{
   internal   class AnalyError : MBType
    {
        /// <summary>
        /// socket连接的IP地址
        /// </summary>
        public string IPAdress { get; set; }

        /// <summary>
        /// 未知设备，无法解析数据
        /// </summary>
        public AnalyError(int type)
        {
            _getDeviceId = type;
        }


        public bool DataAnaly(byte[] buffer, ref ModbusData res)
        {
            res.device_id = buffer[0];
            res.device_cmd = buffer[1];
            res.recdata = buffer;
            res.Dtype = GetDeviceType();
            res.Did = GetDeviceId();
            res.DOper = 0;
            return true;
        }


        private int _getDeviceId;
        public int GetDeviceId()
        {
            return _getDeviceId;
        }

        public string GetDeviceType()
        {
            return "数据解析失败";
        }
    }
}
